package com.controller.admin;

import com.entity.Classroom;
import com.service.IClassRoomService;
import com.service.IProfessionService;
import com.service.IStudentService;
import com.service.ITeacherService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 维护
 *
 * @Author zhangfoshou
 * @Since 2016/1/6
 */
@RequestMapping("/maintain")
@Controller
public class MainTainController {
    @Resource
    private IClassRoomService classRoomService;
    @Resource
    private IStudentService studentService;
    @Resource
    private ITeacherService teacherService;
    @Resource
    private IProfessionService professionService;

    /**
     * 列表
     *
     * @return
     * @author foshou.zhang
     */
    @RequestMapping("/list")
    public String list() {
        return "common/main";
    }

    /**
     * 教室维护
     *
     * @param modelMap
     * @return
     * @author foshou.zhang
     */
    @RequestMapping(value = "/classRoomMaintain", method = RequestMethod.GET)
    public String classRoomMaintain(ModelMap modelMap) {
        List<Classroom> classrooms = classRoomService.selectAll();
        modelMap.addAttribute("classRooms", classrooms);
        return "/maintain/classRoomMaintain";
    }

//    /**
//     * 学生维护
//     *
//     * @param modelMap
//     * @return
//     * @author foshou.zhang
//     */
//    @RequestMapping(value = "/studentMaintain", method = RequestMethod.GET)
//    public String studentMaintain(ModelMap modelMap) {
//        List<Map> student = studentService.selectAllStuInfo();
//        Long majorCount = studentService.selectMajorCount("stuNo");
//        Long selectiveCount = studentService.selectSelectiveCount("stuNo");
//        for (Map map : student) {
//            map.put("majorCount", majorCount);
//            map.put("selectiveCount", selectiveCount);
//        }
//        modelMap.addAttribute("studentMaintain", student);
//        return "/maintain/studentMaintain";
//    }

    /**
     * 教师维护
     *
     * @return
     * @author foshou.zhang
     */
    @RequestMapping(value = "/teachertMaintain", method = RequestMethod.GET)
    public String teachertMaintain(ModelMap modelMap) {
        List<Map> teacherMap = teacherService.selectTeacherInfo();
        modelMap.addAttribute("teacher", teacherMap);
        return "/maintain/teachertMaintain";
    }

    /**
     * 课程维护
     *
     * @return
     * @author foshou.zhang
     */
    @RequestMapping(value = "/courseMaintain", method = RequestMethod.GET)
    public String courseMaintain(ModelMap modelMap) {
        return "/maintain/courseMaintain";
    }

    /**
     * 专业维护
     *
     * @return
     * @author foshou.zhang
     */
    @RequestMapping(value = "/majorMaintain", method = RequestMethod.GET)
    public String majorMaintain(ModelMap modelMap) {
        List<Map> maps = professionService.selectAllProfession();
        modelMap.addAttribute("professions", maps);
        return "/maintain/majorMaintain";
    }
}
